<template>
  <Filed label="影像检查" class="w-full">
    <div class="flex flex-col gap-y-1">
      <div
          class="flex items-center justify-between gap-x-1"
          v-for="(item, index) in info.imageExamAttachs"
          :key="index"
      >
        {{ item.name }}
        <div class="flex">
          <van-button
              class="w-[30px]"
              size="mini"
              color="#85d46c"
              @click="previewFile(item)"
          >阅片
          </van-button>
          <van-button
              class="w-[30px]"
              size="mini"
              color="#0097ec"
              @click="downloadFile(item)"
          >下载
          </van-button>
        </div>
      </div>
    </div>
  </Filed>
  <Filed label="心电检查" class="w-full">
    <div class="flex flex-col gap-y-1">
      <div
          class="flex items-center justify-between gap-x-1"
          v-for="(item, index) in info.ecgAttachs"
          :key="index"
      >
        {{ item.name }}
        <div class="flex">
          <van-button
              class="w-[30px]"
              size="mini"
              color="#85d46c"
              @click="previewFile(item)"
          >预览
          </van-button>
          <van-button
              class="w-[30px]"
              size="mini"
              color="#0097ec"
              @click="downloadFile(item)"
          >下载
          </van-button>
        </div>
      </div>
    </div>
  </Filed>
  <Filed label="病理检查" class="w-full">
    <div class="flex flex-col gap-y-1">
      <div
          class="flex items-center justify-between gap-x-1"
          v-for="(item, index) in info.pathologyAttachs"
          :key="index"
      >
        {{ item.name }}
        <div class="flex">
          <van-button
              class="w-[30px]"
              size="mini"
              color="#85d46c"
              @click="previewFile(item)"
          >预览
          </van-button>
          <van-button
              class="w-[30px]"
              size="mini"
              color="#0097ec"
              @click="downloadFile(item)"
          >下载
          </van-button>
        </div>
      </div>
    </div>
  </Filed>
  <Filed label="检验报告" class="w-full">
    <div class="flex flex-col gap-y-1">
      <div
          class="flex items-center justify-between gap-x-1"
          v-for="(item, index) in info.checkDiagnosticAttachs"
          :key="index"
      >
        {{ item.name }}
        <div class="flex">
          <van-button
              class="w-[30px]"
              size="mini"
              color="#85d46c"
              @click="previewFile(item)"
          >预览
          </van-button>
          <van-button
              class="w-[30px]"
              size="mini"
              color="#0097ec"
              @click="downloadFile(item)"
          >下载
          </van-button>
        </div>
      </div>
    </div>
  </Filed>
  <Filed label="超声内镜" class="w-full">
    <div class="flex flex-col gap-y-1">
      <div
          class="flex items-center justify-between gap-x-1"
          v-for="(item, index) in info.eusAttachs"
          :key="index"
      >
        {{ item.name }}
        <div class="flex">
          <van-button
              class="w-[30px]"
              size="mini"
              color="#85d46c"
              @click="previewFile(item)"
          >预览
          </van-button>
          <van-button
              class="w-[30px]"
              size="mini"
              color="#0097ec"
              @click="downloadFile(item)"
          >下载
          </van-button>
        </div>
      </div>
    </div>
  </Filed>
  <Filed label="其它资料" class="w-full">
    <div class="flex flex-col gap-y-1">
      <div
          class="flex items-center justify-between gap-x-1"
          v-for="(item, index) in info.otherAttachs"
          :key="index"
      >
        {{ item.name }}
        <div class="flex">
          <van-button
              class="w-[30px]"
              size="mini"
              color="#85d46c"
              @click="previewFile(item)"
          >预览
          </van-button>
          <van-button
              class="w-[30px]"
              size="mini"
              color="#0097ec"
              @click="downloadFile(item)"
          >下载
          </van-button>
        </div>
      </div>
    </div>
  </Filed>
</template>

<script lang="ts">
import {defineComponent} from "vue";
import Filed from "./Filed.vue";

export default defineComponent({
  name: "InspectionTesting",
  components: {Filed},
  props: {
    info: Object,
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  beforeCreate() {
  },
  created() {
  },
  beforeMount() {
  },
  mounted() {
  },
  beforeUpdate() {
  },
  updated() {
  },
  methods: {
    // previewFile(file) {
    //   window.open(file.url, "_blank");
    // },
    previewFile(file) {
      const paramsData = {
        uuid: file.uuid,
        serialization: false
      };
      /*HuizhenApi.getReadFilmUrl(paramsData).then(rs => {
        window.open(rs.entity, "_blank");
      })*/
    },
    downloadFile(file) {
      const a = document.createElement("a");
      a.href = file.url;
      a.download = file.name;
      a.click();
      window.URL.revokeObjectURL(a.href);
    },
  },
  beforeUnmount() {
  },
  unmounted() {
  },
});
</script>

<style scoped lang="scss"></style>
